package com.eeepay.eeepay_v2.adapter;

import android.content.Context;

import com.eeepay.eeepay_v2.R;
import com.eeepay.eeepay_v2.model.AgentProfitInfo;
import com.eeepay.v2_library.adapter.ABBaseAdapter;
import com.eeepay.v2_library.adapter.ABViewHolder;

import java.util.HashMap;

/**
 * Created by Ching on 2017/2/27.
 */

public class AddProAdapter extends ABBaseAdapter<AgentProfitInfo> {

    public  HashMap<String, Boolean> getIsSelected() {
        return isSelected;
    }

    private  HashMap<String, Boolean> isSelected;//存放是否现在的集合

    private String bpType;

    public AddProAdapter(Context context) {
        super(context);
        init();
    }

    // 初始化 设置所有checkbox都为未选择
    public void init() {
        isSelected = new HashMap<String, Boolean>();
        for (int i = 0; i < list.size(); i++) {
            isSelected.put(list.get(i).getBpId(), false);
        }
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_agent_add_listview;
    }

    @Override
    public void convert(ABViewHolder holder, AgentProfitInfo model) {
        holder.setText(R.id.tv_title, model.getBpName());
        holder.setText(R.id.tv_intro, "简介：" + model.getRemark());
        switch (model.getBpType()) {
            case "1":
                bpType = "个人";
                break;
            case "2":
                bpType = "个体商户";
                break;
            case "3":
                bpType = "企业商户";
                break;
        }
        holder.setText(R.id.tv_type, "类型：" + bpType);
//        if (model.isApply()) {
//            holder.setImageResource(R.id.iv_tick, R.drawable.icon_check);
//        } else {
//            holder.setImageResource(R.id.iv_tick, R.drawable.icon_uncheck);
//        }

        if (isSelected.containsKey(model.getBpId())) {
            holder.setImageResource(R.id.iv_tick, R.drawable.icon_check);
        } else {
            holder.setImageResource(R.id.iv_tick, R.drawable.icon_uncheck);
        }
    }
}
